﻿@{
    ViewBag.Title = "修改设备信息";
}
@model FMS.UI.Areas.Factory.ViewModel.Factory_Machines
@section headsecion{
    <style type="text/css">
        body {
            margin: 0;
            align-self: center;
        }

        .tbList {
            border: 1px solid #ddd;
            height: 99.5%;
            border-collapse: collapse;
            margin: 0;
            padding: 0;
            width: 100%;
            border-top-width: 0;
            border-bottom-width: 0;
            border-left-width: 0;
            border-right-width: 0;
        }

        .tbList td, th {
            border: 1px solid #ddd;
            padding: 0 5px;
        }

        .tdName {
            text-align: center;
            width: 60px;
            height: 35px;
        }

        .tdweight {
            width: 220px;
        }

        #form0 {
            margin: 0;
            padding: 0;
        }
    </style>
    <script type="text/javascript">
    $(function () {
        var useConPer="@ViewBag.usrCon";
        var conbool = useConPer.toLowerCase();
        if (conbool=="true") {
        $('#ddInDate').datetimebox('setValue', '@ViewBag.factory_Machines_InDate');
        $('#ddUseDate').datetimebox('setValue', '@ViewBag.factory_Machines_UseDate');
        $('#ddOutDate').datetimebox('setValue', '@ViewBag.factory_Machines_OutDate');
        $("#Type_Id").val('@ViewBag.MachinesType_Id');       
        $("#Type_Id2").val("@ViewBag.MachinesType_Id2");   
        $("#Type_Id3").val("@ViewBag.MachinesType_Id3");    
        $("#Type_Machines").val("@ViewBag.Type_Machines");    
        $("#factory_bar_code").val("@ViewBag.factory_bar_code");
        FirstDep();
        $("#dep").append("<option value=" + "@ViewBag.MachinesdepId" + ">" + "@ViewBag.MachinesdepName " + "</optin>");        
            $("#tbList input").attr("disabled", true);
            $("#tbList .easyui-datetimebox").datetimebox("readonly", "readonly");
            $("#factory_Machines_Type_Id").attr("disabled", true);
            $("#factory_Machines_EquipmentStatus_Id").attr("disabled", true);
            $("#company").attr("disabled", true);
            $("#dep").attr("disabled", true);
            $("#factory_Machines_installation_site").attr("disabled", false);
            $("#factory_Machines_UserId").attr("disabled", false);
            $("#enter").attr("disabled", false);
        } else {
            $('#ddInDate').datetimebox('setValue', '@ViewBag.factory_Machines_InDate');
    $('#ddUseDate').datetimebox('setValue', '@ViewBag.factory_Machines_UseDate');
    $('#ddOutDate').datetimebox('setValue', '@ViewBag.factory_Machines_OutDate');
    $("#Type_Id").val('@ViewBag.MachinesType_Id');
    $("#Type_Id").attr("disabled", true);
    $("#Type_Id2").val("@ViewBag.MachinesType_Id2");
    $("#Type_Id2").attr("disabled", true);
    $("#Type_Id3").val("@ViewBag.MachinesType_Id3");
    $("#Type_Id3").attr("disabled", true);
    $("#Type_Machines").val("@ViewBag.Type_Machines");
    $("#Type_Machines").attr("disabled", true);
    $("#factory_bar_code").val("@ViewBag.factory_bar_code");
    $("#factory_bar_code").attr("disabled", true);
    FirstDep();
    $("#dep").append("<option value=" + "@ViewBag.MachinesdepId" + ">" + "@ViewBag.MachinesdepName " + "</optin>");
    $("#company").change(selectDep);
    }


    });

    function Begin() {

    };

    function Complete(xhrobj) {
        $.msgProcess(xhrobj.responseText, function () {
            $.globalHelper.closeCommonWindow();
            $.globalHelper.reloadSeletecTabDataGrid();
        });
    };

    function FirstDep() {
        var sel = $("#dep");
        var id = $("#company")[0].value;
        $.post("/Admin/Department/SelectDep", { "id": id }, function(data) {
            $.each(data, function(name, value) {
                sel.append("<option value=" + value.depId + ">" + value.depName + "</optin>");
            });
        });
    }
    function selectDep() {
        isFirst = false;
        var sel = $("#dep");
        sel.empty();
        if ($('#company  option:selected').text() == '选择公司') {
            sel.attr("disabled", true);
            return;
        }
        sel.attr("disabled", false);
        var id = this.value;


        $.post("/Admin/Department/SelectDep", { "id": id }, function(data) {
            sel.append("<option value='-1'>选择部门</optin>");
            $.each(data, function(name, value) {
                sel.append("<option value=" + value.depId + ">" + value.depName + "</optin>");
            });
        });
    };
    </script>
}
@using (Ajax.BeginForm(new AjaxOptions()
{
    OnBegin = "Begin",
    OnComplete = "Complete"

}))
{
    <table id="tbList" class="tbList">
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Kind_Type_Id)</td>
            <td class="tdweight"><input id="Type_Id" type="text" /> </td>
            <td class="tdName">二级分类</td>
            <td class="tdweight"><input id="Type_Id2" type="text" /> </td>
        </tr>
        <tr>
            <td class="tdName">三级分类</td>
            <td class="tdweight"><input id="Type_Id3" type="text" /> </td>
            <td class="tdName">设备类型</td>
            <td class="tdweight"><input id="Type_Machines" type="text" /> </td>


        </tr>

        <tr>
            <td class="tdName">设备编码</td>
            <td><input type="text" id="factory_bar_code" name="factory_bar_code" /></td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Name)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_Name)@Html.ValidationMessageFor(o => o.factory_Machines_Name)</td>

        </tr>

        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Type)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_Type)@Html.ValidationMessageFor(o => o.factory_Machines_Type)</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Size)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_Size)@Html.ValidationMessageFor(o => o.factory_Machines_Size)</td>
        </tr>


        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_supplier_Id)</td>
            <td>@Html.TextBoxFor(o => o.factory_Supplier_Id_Name, new { disabled = false })</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_UseDate)</td>
            <td><input id="ddUseDate" type="text" class="easyui-datetimebox" required="required" name="factory_Machines_UseDate"></td>

        </tr>
       
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_InDate)</td>
            <td><input id="ddInDate" type="text" class="easyui-datetimebox" required="required" name="factory_Machines_InDate"></td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_OutDate)</td>
            <td> <input id="ddOutDate" type="text" class="easyui-datetimebox" required="required" name="factory_Machines_OutDate"></td>
        </tr>

        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_factory_number)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_factory_number, new { id = "factory_Machines_factory_number" })@Html.ValidationMessageFor(o => o.factory_Machines_factory_number)</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_KW)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_KW, new { id = "factory_Machines_KW" })@Html.ValidationMessageFor(o => o.factory_Machines_KW)</td>
        </tr>

        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Price)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_Price)@Html.ValidationMessageFor(o => o.factory_Machines_Price)</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_depreciation)</td>
            <td>@Html.TextBoxFor(o => o.factory_depreciation)@Html.ValidationMessageFor(o => o.factory_depreciation)</td>
        </tr>

        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_networth)</td>
            <td>@Html.TextBoxFor(o => o.factory_networth)@Html.ValidationMessageFor(o => o.factory_networth)</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_installation_site)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_installation_site, new { id = "factory_Machines_installation_site" })@Html.ValidationMessageFor(o => o.factory_Machines_installation_site)</td>

        </tr>
        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.Factory_Machines_Company_Id)</td>
            <td>@Html.DropDownListFor(o => o.Factory_Machines_Company_Id, ViewBag.Machines_Company as IEnumerable<SelectListItem>, "选择公司", new { style = "width:135px ", id = "company" })</td>

            <td class="tdName">部门名称</td>
            <td><select id="dep" name="factory_Machines_Department_Id" style="width:135px"></select></td>

        </tr>

        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_EquipmentStatus_Id)</td>
            <td >@Html.DropDownListFor(o => o.factory_Machines_EquipmentStatus_Id, ViewBag.Machines_EquipmentStatus as IEnumerable<SelectListItem>, "", new { style = "width:135px ", select = "size:10", id = "factory_Machines_EquipmentStatus_Id" })</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_Type_Id)</td>
            <td >@Html.DropDownListFor(o => o.factory_Machines_Type_Id, ViewBag.Machines_Type as IEnumerable<SelectListItem>, "", new { style = "width:135px ", select = "size:10", id = "factory_Machines_Type_Id" })</td>


        </tr>

        <tr>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_UseState_Id)</td>
            <td>@Html.DropDownListFor(o => o.factory_Machines_UseState_Id, ViewBag.Machines_UseState as IEnumerable<SelectListItem>, "", new { style = "width:135px ", select = "size:10" })</td>
            <td class="tdName">@Html.DisplayNameFor(o => o.factory_Machines_UserId)</td>
            <td>@Html.TextBoxFor(o => o.factory_Machines_UserId, new { id = "factory_Machines_UserId" })@Html.ValidationMessageFor(o => o.factory_Machines_UserId)</td>
        </tr>


        <tr>
            <td colspan="4" style="text-align: center; border: 0 solid white; padding-top:7px"><input id="enter" type="submit" value="确定" style="height: 27px; width: 68px;  cursor: pointer" /></td>
        </tr>
    </table>
}

